package scala.pattern

/**
 * 模式守卫
 */
object MatchGuardTest1 {
  def main(args: Array[String]): Unit = {

   def abs(x:Int) = x match {
      case i: Int if i >= 0 => i;
      case j: Int if j < 0 => -j;
      case _ => "exit!"
    }

    println(abs(1))
    println(abs(-5))
  }
}
